import request from ".";

//获取用户列表
export const userList = () => {
  return request({
    url: "/usermanage/userList",
    method: "get",
  });
};

//查找用户
export const findUser = (uname) => {
  return request({
    url: "/usermanage/findUser",
    method: "get",
    params: {
      //    uname:uname
      uname: uname,
    },
  });
};

//增加用户
export const addUser = (form) => {
  return request({
    url: "/usermanage/addUser",
    method: "post",
    params: {
      uname: form.uname,
      password: form.password,
      usex: form.usex,
      num: 0,
      role_id: form.role_id,
    },
  });
};
//修改用户
export const updateUser = (form) => {
  return request({
    url: "/usermanage/updateUser",
    method: "post",
    data: {
      uid: form.uid,
      uname: form.uname,
      password: form.password,
      usex: form.usex,
      num: form.num,
      role_id: form.role_id,
    },
  });
};

//删除用户
export const deleteUser = (uid) => {
  return request({
    url: "/usermanage/deleteUser",
    method: "post",
    params: {
      uid: uid,
    },
  });
};

//查找用户
export const findUserById = (uid) => {
  return request({
    url: "/user/" + uid,
    method: "get",
  });
};

export const changeInfo = (userInfo) => {
  return request({
    url: "/usermanage/updateUser",
    method: "post",
    data: {
      uid: userInfo.uid,
      uname: userInfo.username,
      usex: userInfo.usex,
      password: userInfo.password,
    },
  });
};
